Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MIDI compatibilty (usb) #2322

Merged
merged 3 commits into from
Jul 2, 2020
Merged

Add MIDI compatibilty (usb) #2322

merged 3 commits into from
Jul 2, 2020

Conversation

sksum
Copy link
Member

@sksum sksum commented Jun 6, 2020

I am using the web Midi api available on https://www.w3.org/TR/webmidi/
to communicate with a physical midi keyboard ,
I have added a button(MIDI) in the music Keyboard widget , (to be pressed once connected with keyboard ) ,I would like to add a svg for this button also .
Currently this works with alphabet pitches (only FLATS ) u can use this keyboard for testing -

midi (1).zip

@walterbender
Copy link
Member

@sksum can you please do a rebase so that the old commits (one from April, for example) are not included?

@pikurasa do you have a midi keyboard? could you please test this?

@pikurasa
Copy link
Collaborator

pikurasa commented Jun 7, 2020

I have a midi keyboard but no midi cord to connect it to the computer. I will need to find or buy one.

I can't wait to test.

map midi input data to the keys on virtual MusicKeyboard .

handles cblk2 is null error
decrement function will work even when cblk2 : null
@sksum
Copy link
Member Author

sksum commented Jun 8, 2020

If anyone wants to try this feature , I used a midi simulator on my android for testing . All you need to remember is to change your usb connection setting to Midi ( mtp is default usually).

@sksum
Copy link
Member Author

sksum commented Jun 8, 2020

https://play.google.com/store/apps/details?id=com.dreamhoundstudios.keyboard&hl=en_US
this is the link to the midi app I was using , you need to change "output" to your pc/laptop port

hello

@pikurasa
Copy link
Collaborator

@sksum

All you need to remember is to change your usb connection setting to Midi ( mtp is default usually).

Is there a reference for how to do this?

@sksum
Copy link
Member Author

sksum commented Jun 15, 2020

sorry if I wasn't clear earlier ,
I found this at https://source.android.com/devices/audio/midi

You also need to do either of the following:

Go to Settings > Developer options > Networking and check the box for MIDI in the Select USB
Configuration dialog.

While attached to the USB host, pull down from the top of screen, select the entry USB for, and then select MIDI.

this pic might help :

android-file-transfer-usb-notification-100812852-large

allow solfege and sharps/flats in midi.
@pikurasa
Copy link
Collaborator

Ok, so both my phone and the tablet I have are too old to have this MIDI functionality.

I was going to say the following, but I got JACK to work! I will leave the part with my bug report below just in case it shows up for anyone else.

Successful file:
midi-jack-3.ogv.zip
^ it looks like this only captured ambient audio as well... oh, well...

If anyone can figure out what I did right in a reproducible way it may be helpful for further testing.

So... I tried Jack, which I knew--theoretically--should work since what Jack does is connect sound from (any) outputs to (any) inputs. I don't really know what I am doing with jack (I don't know jack), but somehow I got it to work.

Based on this configuration of using Jack, I did run into some issues.
1. The notes all stack on top of each other, ignoring time and order.
2. The notes are all calculated at enormously large values.

Screenshot that is somewhat telling of my configuration (if, indeed, the issue is specific to piping midi via jack)
Screenshot at 2020-06-15 15:05:24 jack

Video files of issue as well as my jack config file:
midi-jack-test.zip

^ it was at this point I decided to re-record as these videos do not have the system audio, just ambient.

@pikurasa
Copy link
Collaborator

We may need a message to the user after they click the button that notifies them that MB is now listening for midi input. Also, do they need to press it every time or is this just to get the browser to ask for MIDI permissions?

@sksum
Copy link
Member Author

sksum commented Jun 15, 2020

We would need to press it everytime there are new additions/deletions in pitches inside the keyboard.
Also , I think the bugs you were getting might be related to this.
I will look for a fix .

better handling of midi access
@sksum
Copy link
Member Author

sksum commented Jun 19, 2020

I have added some confirmation messages . Could you please test for those bugs again

@pikurasa
Copy link
Collaborator

I am no longer able to reproduce the bug from before--even if I try initiating the midi listener in MB before starting Jack and Jack keyboard.

One thing, however, is I do not hear any playback--neither when I am playing the JACK keyboard, nor when I reset the playback button in the widget. When I export, I can hear the sound, so I know it is not a deeper issue than just the widget itself.

@walterbender
Copy link
Member

I have jack installed but how to I connect it to MB?

@pikurasa
Copy link
Collaborator

I used

  1. QJackCtl
  2. Jack Keyboard

(and dependencies)

I start by running QJackCtl first, then start Jack Keyboard. In Jack Keyboard, for "Connect to" I choose "System MIDI 1".

There may be some configurations I made in QJackCtl that are set properly (but unsure).

My .xml config file for QJackCtl is:

<!DOCTYPE patchbay>
<patchbay name="try-midi-2" version="0.4.2">
 <output-sockets>
  <socket client="jack-keyboard" name="jack-keyboard 1" type="jack-midi" exclusive="off">
   <plug>midi_out</plug>
  </socket>
 </output-sockets>
 <input-sockets>
  <socket client="Mbox 2" name="Mbox 1" type="alsa-midi" exclusive="off">
   <plug>Mbox 2 MIDI 1</plug>
  </socket>
 </input-sockets>
 <slots/>
 <cables/>
</patchbay>

@walterbender walterbender merged commit 99bfac0 into sugarlabs:master Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants